package UILayer;
import java.util.Scanner;

public abstract class InOut
{
    protected static String logUs;
    protected static int access = 0;
    
    int readInt()
    {
        Scanner keyboard = new Scanner(System.in);
        String s = keyboard.nextLine();
        
        try{
            return Integer.parseInt(s);
        }
        catch(NumberFormatException e){
            return -1;
        }
    }
    
    
    long readLong()
    {
        Scanner keyboard = new Scanner(System.in);
        String s = keyboard.nextLine();
        
        try{
            return Long.parseLong(s);
        }
        catch(NumberFormatException e){
            return -1;
        }
    }
    
    double readDouble()
    {
        Scanner keyboard = new Scanner(System.in);
        String s = keyboard.nextLine();
        
        try{
            return Double.parseDouble(s);
        }
        catch(NumberFormatException e){
            return -1;
        }
    }
    
    String readString()
    {
        Scanner keyboard = new Scanner(System.in);
        return keyboard.nextLine();
    }
    
    // ********************************************************************************** \\
    
    
    double inputDouble(String param)
    {
        System.out.print(param);
        return (double)readDouble();
    } 
    
    
    int inputInt(String param)
    {
        System.out.print(param);
        return (int)readInt();
    }
    
    long inputLong(String param)
    {
        System.out.print(param);
        return (long)readLong();
    }
    
    String inputString(String param)
    {
        System.out.print(param);
        return (String)readString();
    }
    
    void waitK()
    {
        inputString("\nPress Enter to continue ...");  
    }
    
    public void erase() {System.out.println("\f");} // erase the text frame
    
    public void erase(int opt) { erase(); welcome(); }  // erase and welcome
    
    public void welcome() { if(logUs!=null) System.out.println(" -> Welcome "+logUs+"\n"); }
    
    public void writeEnd() { erase();  System.out.println(" -> The system is shuting down ..."); }
    
    public void print(String param) {System.out.println(param);}
    
    public void printMenu(String[] fields)
    {
        int k=0;
        print("########## "+fields[0]+" ##########");
        for(int i=1;i<fields.length;i++) { print((++k)+". "+fields[i]);}
        print((++k)+". EXIT");
    }
    
    public boolean haveAccess() 
    { 
        if(access==0) print("You don't have access.");
        return (access==1); 
    }
}
